/**
 * @author BoLiang
 */
if (typeof accedo === "undefined") {
	accedo = {};
}
if (typeof accedo.achievement === "undefined") {
	accedo.achievement = {};
}

accedo.achievement.achiRightShow = {
		divRightCtn: null,
		divRightInner: null,
		oldOnkeydownFunc: null,
		
		init: function() {
			this.divRightCtn = null;
			this.divRightInner = null; 
			this.oldOnkeydownFunc = null;
		},
		
		createRightDiv: function() {
			
			var divAccedoFriendsNode = document.createElement("div"); 
			divAccedoFriendsNode.id = "right1"; 
			divAccedoFriendsNode.className = "divAFbutton"; 
			divAccedoFriendsNode.style.borderColor = "yellow"; 
			
			var divFacebookNode = document.createElement("div"); 
			divFacebookNode.id = "right2"; 
			divFacebookNode.className = "divFBbutton"; 
			
			var divTwitterNode = document.createElement("div");
			divTwitterNode.id = "right3"; 
			divTwitterNode.className = "divTTbutton"; 
			
			this.divRightInner = document.createElement("div");
			this.divRightInner.id = "divAchiRightInner"; 
			this.divRightInner.appendChild(divAccedoFriendsNode); 
			this.divRightInner.appendChild(divFacebookNode); 
			this.divRightInner.appendChild(divTwitterNode); 
			
			this.divRightCtn = document.createElement("div"); 
			this.divRightCtn.id = "divAchiRightCtn"; 
			this.divRightCtn.appendChild(this.divRightInner); 
			
			
			
			var bodyNode = document.getElementsByTagName("body")[0]; 
			bodyNode.appendChild(this.divRightCtn); 
			
		},
		
		appendRight:function() {
			this.init(); 
			this.createRightDiv(); 
			this.divRightInner.className = "startRightInner";
			
			accedo.achievement.achiRightShow.oldOnkeydownFunc = document.onkeydown;
			document.onkeydown = function(e) {
				accedo.achievement.achiRightShow.keysControl(e);
			};
		},
		
		removeRight: function() {
			this.divRightInner.className = "endRightInner";
			document.onkeydown = this.oldOnkeydownFunc;
			setTimeout(function(){ 
				var bodyNode = document.getElementsByTagName("body")[0];
				bodyNode.removeChild(accedo.achievement.achiRightShow.divRightCtn); 
			},400);
		},
		
		keysControl : function(e) {
			e = window.event || e;
			switch (e.keyCode) {
			// esc button
			case 27:
				this.removeRight();
				break;
			// left button
			case 37:
				this.removeRight();
				break;
			// up button
			case 38:
				break;
			// right button
			case 39:
				break;
			// down button
			case 40:
				break;
			// enter button
			case 13:
				this.removeRight();
				accedo.achievement.achiFriendsShow.appendFri("Bosse"); 
				break;
			default:
				break;
			}
		},
};
